package cn.zyjw.controller;

import cn.zyjw.model.LoginForm;
import cn.zyjw.model.LoginUser;
import cn.zyjw.model.R;
import cn.zyjw.service.LoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "用户登录")
public class LoginController {


    @Autowired
    private LoginService loginService;

    @PostMapping("/login")
    @ApiOperation("用户登录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "loginForm", value = "用户登录信息")
    })
    public R<LoginUser> login(@RequestBody LoginForm loginForm) {
        LoginUser login = loginService.login(loginForm);
        return R.ok(login);
    }

}
